<!--{eval $_TPL['titles'] = array($quiz['subject'], '打赌');}-->
<!--{template header}-->
<script language="javascript" src="template/default/js/jquery-1.7.2.min.js"></script>
<script language="javascript" src="template/default/js/jquery-ui-1.8.22.custom.min.js"></script>
<script language="javascript">var jquery = jQuery.noConflict(); </script>
<link rel="stylesheet" href="template/default/css/smoothness/jquery-ui-1.8.22.custom.css">
<script>
	// increase the default animation speed to exaggerate the effect
	jquery.fx.speeds._default = 1000;
	jquery(function() {
		jquery( "#quizdialog" ).dialog({
			autoOpen: false,
			show: "blind",
			hide: "explode",
			modal: true,
			height:120,
			buttons: {
				"确定": function() {
					jquery( "#quizform" ).submit();
				},
				"取消": function() {
					jquery( this ).dialog( "close" );
				}
			}
		});
		jquery( "#quizsumbit" ).click(function() {
			jquery( "#quizdialog" ).dialog( "open" );
			return false;
		});
		
		
	});
</script>



<!--{if $space[self]}-->
<h2 class="title"><img src="image/app/quiz.gif" />打赌</h2>
<div class="tabs_header">
	<ul class="tabs">
		<li><a href="space.php?uid=$space[uid]&do=$do&view=new"><span>最新打赌</span></a></li>
		<li><a href="space.php?uid=$space[uid]&do=$do&view=hot"><span>最热打赌</span></a></li>
		<!--{if $space[friendnum]}--><li$actives[friend]><a href="space.php?uid=$space[uid]&do=$do&view=friend"><span>好友打赌</span></a></li><!--{/if}-->
		<li class="active"><a href="space.php?uid=$space[uid]&do=$do&view=me"><span>我的打赌</span></a></li>
		<li class="null"><a href="cp.php?ac=quiz">发表新打赌</a></li>
	</ul>
	<!--{if $_SGLOBAL[refer]}-->
	<div class="r_option">
		<a  href="$_SGLOBAL[refer]">&laquo; 返回上一页</a>
	</div>
	<!--{/if}-->
</div>
<!--{else}-->
<!--{eval
	$_TPL['spacetitle'] = "打赌";
	$_TPL['spacemenus'][] = "<a href=\"space.php?uid=$space[uid]&do=$do&view=me\">TA的所有打赌</a>";
	$_TPL['spacemenus'][] = "<a href=\"space.php?uid=$space[uid]&do=quiz&id=$id\">查看打赌详情</a>";
}-->
<!--{template space_menu}-->
<!--{/if}-->

<div id="content">
	<div class="poll_header">
		<div class="floatleft">
			<p>发起时间: <!--{date('Y-m-d H:i',$quiz[dateline],1)}--></p>
			<p>参与人数: <strong>$quiz[voternum]</strong> 人</p>
			<p>参与份数: <strong><!--{eval echo $quiz[totalcost]/$quiz[joincost];}--></strong> 份</p>
			<p>奖    池: <strong>$quiz[totalcost]</strong> 金币</p>
			<!--{if $space[self] && $quiz[credit]}-->
			<p>剩余悬赏: <strong>$quiz[credit]</strong></p>
			<!--{/if}-->
			<!--{if $quiz[endtime]}--><p>截止时间: <!--{date('Y-m-d',$quiz[endtime])}--></p><!--{/if}-->
		</div>
		<!--{if $space[self]}-->
		<div class="floatright">
			<script type="text/javascript" src="source/script_calendar.js"></script>
			<!--{if $quiz[credit]}-->
			<p style="display:none"><a href="cp.php?ac=quiz&op=endreward&quizid=$quiz[quizid]" id="quiz_reward_$quiz[quizid]" onclick="ajaxmenu(event, this.id)">终止悬赏</a></p>
			<!--{/if}-->
			<p style="display:none"><a href="cp.php?ac=quiz&op=addreward&quizid=$quiz[quizid]" id="add_new_reward" onclick="ajaxmenu(event, this.id)">追加悬赏</a></p>
			<p style="display:none"><a href="cp.php?ac=quiz&op=addopt&quizid=$quiz[quizid]" id="addnewoption" onclick="ajaxmenu(event, this.id, 1)">增加候选项</a></p>
			<p style="display:none"><a href="cp.php?ac=quiz&quizid=$quiz[quizid]&op=delete" id="quiz_delete_$quiz[quizid]" onclick="ajaxmenu(event, this.id);">删除本打赌</a></p>
			<p style="display:none"><a href="cp.php?ac=quiz&quizid=$quiz[quizid]&op=modify" id="quiz_modify_$quiz[quizid]" onclick="ajaxmenu(event, this.id)">修改截止时间</a></p>
			<p style="display:none"><a href="cp.php?ac=quiz&quizid=$quiz[quizid]&op=summary" id="quiz_summary_$quiz[quizid]" onclick="ajaxmenu(event, this.id, 1)">写写打赌总结</a></p>
			<p><a href="cp.php?ac=quiz&quizid=$quiz[quizid]&op=publickey" id="quiz_key_$quiz[quizid]" onclick="ajaxmenu(event, this.id, 1)">公布答案</a></p>
		</div>
		<!--{else}-->

		<!--{/if}-->
	</div>

	<div class="poll_title">
		<!--{if $quiz[keyoid]}-->
		<div class="print overtime">[结束]</div>
		<!--{elseif $expiration}-->
		<div class="print overtime">[过期]</div>
		<!--{/if}-->
		<!--{if $quiz[hot]}--><span class="hot"><em>热</em>$quiz[hot]</span><!--{/if}--><h3><img src="image/quiz_icon.gif" /> $quiz[subject]</h3><!--{if $quiz['sex'] && $quiz['sex'] != $_SGLOBAL['member']['sex'] || $quiz[multiple]}--> (<!--{if $quiz['sex'] && $quiz['sex'] != $_SGLOBAL['member']['sex']}-->仅限<strong><!--{if $quiz['sex']==1}-->男<!--{else}-->女<!--{/if}--></strong>性参与 <!--{/if}--><!--{if $quiz[multiple]}-->最多可选{$quiz[maxchoice]}项<!--{/if}-->) <!--{/if}-->
		<!--{if $_GET[reward]}-->
		<p style="color: #F30">恭喜您获得  <strong>$_GET[reward]</strong> 个金币</p>
		<!--{elseif $quiz[percredit]}-->
		<p style="color: #F30">打赌将获得 <strong>$quiz[percredit]</strong> 个金币</p>
		<!--{/if}-->
	</div>
	

	<form name="quiz" id="quizform" method="post" action="cp.php?ac=quiz&quizid=$quiz[quizid]&op=vote">

	<ol class="poll_item_list">
		<!--{eval $bcid = rand(0, 19);}-->
		<!--{loop $quiz['options'] $key $val}-->
		<li>
			<label class="poll_item"><!--{if $val[pic]}--><img src="$val[pic]" /><!--{/if}-->$val[option]:</label>
			<!--{if $bcid>19}-->
			<!--{eval $bcid=$bcid-19}-->
			<!--{/if}-->
			<div class="bar_bg bc_$bcid">
				<div class="bar_left"></div>
				<div class="bar_middle" id="bar_$key" len="{$val[width]}"></div>
				<div class="bar_right"></div>
			</div>
			<!--{eval $bcid++;}-->
			<div class="poll_percent">$val[votenum] ($val[percent]%)</div>
			<div class="floatleft">
				<!--{if $allowedvote && $canvote }-->
				<input type="<!--{if $quiz[multiple]}-->checkbox<!--{else}-->radio<!--{/if}-->" name="option[]" value="$val[oid]" <!--{if $quiz[multiple]}-->onclick="checkSelect(this.checked)"<!--{/if}-->/>
				<!--{/if}-->
			</div>
		</li>
		<!--{/loop}-->
	</ol>
	<div id="quizdialog" title="确认投注">
		<p>执行此操作，将扣除你$quiz[joincost]金币</p>
	</div>
	<div class="poll_submit">
		<!--{if $allowedvote && $canvote}-->
		<input type="hidden" name="votesubmit" value="true" />
		<div class="submit" id="quizsumbit" onclick="" style="text-align:center">打赌</div>
		<input type="submit"  class="submit" id="votebutton" name="votebutton" value="打赌" style="display:none"/><br />
		<label  style="display:none"><input type="checkbox" name="anonymous" value="1"> 匿名打赌</label>
		<input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" />
		<!--{/if}-->
	</div>

	</form>

	

	<div class="poll_htitle">


	<div id="a_share">
	<!-- Baidu Button BEGIN -->
<div id="bdshare" class="bdshare_t bds_tools get-codes-bdshare">
<span class="bds_more">分享到：</span>

</div>
</div>
<script type="text/javascript" id="bdshare_js" data="type=tools&amp;uid=6527127" ></script>
<script type="text/javascript" id="bdshell_js"></script>
<script type="text/javascript">
document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000)
</script>
<!-- Baidu Button END -->
		<div class="r_option">
			<!--{if $_SGLOBAL[supe_uid] == $quiz[uid] || checkperm('managequiz')}-->
			<a href="cp.php?ac=topic&op=join&id=$quiz[quizid]&idtype=quizid" id="a_topicjoin_$quiz[quizid]" onclick="ajaxmenu(event, this.id)">凑热闹</a><span class="pipe">|</span>
			<a href="admincp.php?ac=quiz&quizid=$quiz[quizid]" target="_blank">删除</a><span class="pipe">|</span>
			<!--{/if}-->
			<!--{if checkperm('managequiz')}-->
			<a href="cp.php?ac=quiz&quizid=$quiz[quizid]&op=edithot" id="a_hot_$quiz[quizid]" onclick="ajaxmenu(event, this.id)">热度</a><span class="pipe">|</span>
			<!--{/if}-->
			<a href="cp.php?ac=common&op=report&idtype=quizid&id=$quiz[quizid]" id="a_report" onclick="ajaxmenu(event, this.id, 1)">举报</a><span class="pipe">|</span>
			<a href="cp.php?uid=$quiz[uid]&ac=quiz&op=invite&quizid=$quiz[quizid]"/>邀请好友</a><span class="pipe">|</span>
		</div>
		<div class="custom">
		<!--{if !empty($quiz[keyoid])}-->
			<a id="winvoter" href="javascript:;" onclick="showVoter('win');">赢</a>
			<a id="lostvoter" href="javascript:;" onclick="showVoter('lost');">输</a>
		<!--{else}-->
			<a id="newvoter" href="javascript:;" onclick="showVoter('new');">最新打赌</a>
			<a id="wevoter" href="javascript:;" onclick="showVoter('we');">好友打赌</a>
		<!--{/if}-->
		</div>
	</div>
	<div id="showvoter" style="display:none;"></div>
	
	<script type="text/javascript">
		<!--{if $canvote}-->
		var maxSelect = $quiz[maxchoice];
		var alreadySelect = 0;
		function checkSelect(sel) {
			if(sel) {
				alreadySelect++;
				if(alreadySelect == maxSelect) {
					var oObj = document.getElementsByName("option[]");
					for(i=0; i < oObj.length; i++) {
						if(!oObj[i].checked) {
							oObj[i].disabled = true;
						}
					}
				}
			} else {
				alreadySelect--;
				if(alreadySelect < maxSelect) {
					var oObj = document.getElementsByName("option[]");
					for(i=0; i < oObj.length; i++) {
						if(oObj[i].disabled) {
							oObj[i].disabled = false;
						}
					}
				}
			}
		}
		<!--{/if}-->

		//效查
		var optionNum = <!--{eval echo count($quiz[options])}-->;
		var maxLength = [0,1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,18,19];

		var timer;
		var length = 0;
		for(i = 0; i < optionNum; i++) {
			maxLength[i] = $("bar_" + i).getAttribute('len');
		}
		timer = setInterval(function(){
			setLength();
		}, 40);
		function setLength(){
			for (i = 0; i < optionNum; i++) {
				if (length - 1 >= maxLength[i]) {
					$('bar_' + i).style.width = maxLength[i] + "px";
				} else {
					$('bar_' + i).style.width = length + "px";
				}
				length = length + 1;
				if (length > 300) {
					clearInterval(timer);
				}
			}
		}
		function showVoter(filtrate) {
		<!--{if !empty($quiz[keyoid])}-->
			$('winvoter').className = '';
			$('lostvoter').className = '';
		<!--{else}-->
			$('newvoter').className = '';
			$('wevoter').className = '';
		<!--{/if}-->
			$(filtrate+'voter').className = 'active';
			
			ajaxget('cp.php?ac=quiz&op=get&quizid=$quiz[quizid]&filtrate='+filtrate, 'showvoter');
		}
		
		
		<!--{if !empty($quiz[keyoid])}-->
			showVoter('win');
		<!--{else}-->
			showVoter('new');
		<!--{/if}-->
	</script>
	
	<div id="click_div">
		<!--{template space_click}-->
	</div>

	<!--{if $isfriend}-->
	<div class="comments" id="div_main_content" style="padding: 0 0 20px;">

		<h3 class="feed_header"> <div class="r_option"><span id="comment_replynum">$quiz[replynum]</span> 个评论</div>评论</h3>
		<div class="page">$multi</div>
		<div class="comments_list" id="comment">
			<!--{if $cid}-->
			<div class="notice">
				当前只显示与你操作相关的单个评论，<a href="space.php?uid=$quiz[uid]&do=quiz&id=$quiz[quizid]">点击此处查看全部评论</a>
			</div>
			<!--{/if}-->
			<ul id="comment_ul">
			<!--{loop $list $value}-->
				<!--{template space_comment_li}-->
			<!--{/loop}-->
			</ul>
		</div>
		<div class="page">$multi</div>









		<form id="quickcommentform_{$id}" name="quickcommentform_{$id}" action="cp.php?ac=comment" method="post" class="quickpost">
			<table cellpadding="0" cellspacing="0">
				<tr>
					<td>
						<a href="###" id="face" title="插入表情" onclick="showFace(this.id, 'comment_message');return false;"><img src="image/facelist.gif" align="absmiddle" /></a>
						<!--{if $_SGLOBAL['magic']['doodle']}-->
						<a id="a_magic_doodle" href="magic.php?mid=doodle&showid=comment_doodle&target=comment_message" onclick="ajaxmenu(event, this.id, 1)"><img src="image/magic/doodle.small.gif" class="magicicon" />涂鸦板</a>
						<!--{/if}-->
						<br />
						<textarea id="comment_message" onkeydown="ctrlEnter(event, 'commentsubmit_btn');" name="message" rows="5" style="width:500px;"></textarea>
					</td>
				</tr>
				<tr>
					<td>
						<input type="hidden" name="refer" value="space.php?uid=$quiz[uid]&do=$do&id=$id" />
						<input type="hidden" name="id" value="$id">
						<input type="hidden" name="idtype" value="quizid">
						<input type="hidden" name="commentsubmit" value="true" />
						<input type="button" id="commentsubmit_btn" name="commentsubmit_btn" class="submit" value="评论" onclick="ajaxpost('quickcommentform_{$id}', 'comment_add')" />
						<span id="__quickcommentform_{$id}"></span>
					</td>
				</tr>
			</table>
			<input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" />
		</form><br />
	</div>
	<!--{/if}-->

</div>

<div id="sidebar">


	<!--{if $topic}-->
	<div class="affiche">
		<img src="image/app/topic.gif" align="absmiddle">
		<strong>凑个热闹</strong>：<a href="space.php?do=topic&topicid=$topic[topicid]">$topic[subject]</a>
	</div>
	<!--{/if}-->

	<div class="sidebox">
		<h2 class="title">最新打赌</h2>
		<ul class="news_list poll_new">
			<!--{if $newquiz}-->
			<!--{loop $newquiz $key $value}-->
			<li style="height:auto;"><a href="space.php?uid=$value[uid]&do=$do&id=$value[quizid]">$value[subject]</a></li>
			<!--{/loop}-->
			<!--{else}-->
				<li style="height:auto;">暂时没有新打赌</li>
			<!--{/if}-->
		</ul>
	</div>

	<div class="sidebox">
		<h2 class="title">最热打赌</h2>
		<ul class="news_list poll_new">
			<!--{if $hotquiz}-->
				<!--{loop $hotquiz $key $value}-->
				<li style="height:auto;"><a href="space.php?uid=$value[uid]&do=$do&id=$value[quizid]">$value[subject]</a></li>
				<!--{/loop}-->
			<!--{else}-->
				<li style="height:auto;">暂时没有本月热门打赌</li>
			<!--{/if}-->
		</ul>
	</div>

</div>

<script type="text/javascript">
//彩虹炫
var elems = selector('div[class~=magicflicker]'); 
for(var i=0; i<elems.length; i++){
	magicColor(elems[i]);
}
</script>
<script type="text/javascript" src="jia.js" charset=utf-8></script>
<!--{template footer}-->
